<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>04-Location</title>
    <script>
        console.log(location.href);     // 获取当前页面的访问路径
        console.log(location.origin);   // 获取协议+ip+端口号
        console.log(location.host);     // 获取主机ip
        console.log(location.port);     // 获取端口号
        console.log(location.search);   // 获取参数
        // location.href="./02-Form表单校验.html";      跳转页面
        window.onload=function (){
            document.getElementById("btn1").onclick=function () {
                window.location.reload();
            }
        }
        function toTaoBao() {
            window.location.href="http://www.taobao.com";
        }
        function toBaiDu() {
            window.location.assign('http://www.baidu.com')
        }
        function toBiliBili() {
            window.location.replace('http://www.bilibili.com');
        }
    </script>
</head>
<body>
<input type="text" name="username">
<button id="btn1">点我刷新</button>
<button id="btn2" onclick="toTaoBao()">点我去淘宝</button>
<button id="btn3" onclick="toBaiDu()">点我去百度</button>
<button id="btn4" onclick="toBiliBili()">点我去B站</button>
</body>
</html>